<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Customer Management</title>
<script type="text/javascript">

function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true
	}

	function validate_fields(){
		//validate all the fields
	  var firstname = document.add_customer.firstname.value;
	  if(firstname == ''){
	  	alert('You must fill in the First Name field');
	  	document.add_cus
	  	return false;
	  }
	  var lastname = document.add_customer.lastname.value;
	  if(lastname == ''){
	  	alert('You must fill in the Last Name field');
 		return false;
	  }
	  var addr = document.add_customer.addr.value;
	  if(addr == ''){
	  	alert('You must fill in the Address field');
 		return false;
	  }

	  var suburb = document.add_customer.suburb.value;
	  if(suburb == ''){
	  	alert('You must fill in the Suburb field');
 		return false;
	  }
	  var state = document.add_customer.state.value;
	  if(state == ''){
	  	alert('You must fill in the State field');
 		return false;
	  }

	  var zip = document.add_customer.zip.value;
	  if(zip == ''){
	  	alert('You must fill in the Post Code field');
 		return false;
	  }
	  var email = document.add_customer.email.value;
	  if(email == ''){
	  	alert('You must fill in the Email field');
	 	return false;
	  }else{
	  	var pass = echeck(email);
	  	if(pass == false) return false;
	  }
	  var url = document.add_customer.url.value;
		  if(url != ''){
		  var pass = isUrl(url);
		  if(pass == false){
		   alert('Invalid URL');
		   return false;
		  }
	  }
	  return true;

	}


</script>
</head>
<body>
<form id="add_customer" name="add_customer" method="post"
	action="customer_manip.php" onsubmit="return validate_fields()">
<input type="hidden" id="action" name="action" value="add" />
<table width="60%" align="center" cellspacing="10">

	<tr>
		<td align="center" colspan="3"><label><b>
		<h3>Add Customer</h3>
		</b></label></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="title">Title</label></td>
		<td></td>
		<td><select id="title" name="title">
			<option value="Mr." selected="selected">Mr.</option>
			<option value="Ms.">Ms.</option>
			<option value="Ms.">Mrs.</option>
			<option value="Ms.">Miss</option>
			<option value="Ms.">Sir.</option>
			<option value="Ms.">Prof.</option>
		</select></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="firstname">First
		Name* </label></td>
		<td></td>
		<td><input id="firstname" name="firstname" style="width: 158px" /></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="lastname">Last
		Name*</label></td>
		<td></td>
		<td><input id="lastname" name="lastname" style="width: 158px" /></td>
	</tr>
	<tr>
		<td width="30%" align="right">Address</td>
		<td></td>
		<td><input id="addr" name="addr" style="width: 278px"></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="addr2">Suburb</label></td>
		<td></td>
		<td><input id="suburb" name="suburb" style="width: 141px" /></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="state">State </label></td>
		<td></td>
		<td><input id="state" name="state" style="width: 140px" /></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="country">Country
		</label></td>
		<td></td>
		<td><select id="country" name="country" class=""
			onChange="refreshCountry(this, true);">
			<option value="US" selected>United States</option>
			<option value="AL">Albania</option>
			<option value="DZ">Algeria</option>
			<option value="AD">Andorra</option>
			<option value="AO">Angola</option>
			<option value="AI">Anguilla</option>
			<option value="AG">Antigua and Barbuda</option>
			<option value="AR">Argentina</option>

			<option value="AM">Armenia</option>
			<option value="AW">Aruba</option>
			<option value="AU">Australia</option>
			<option value="AT">Austria</option>
			<option value="AZ">Azerbaijan Republic</option>
			<option value="BS">Bahamas</option>
			<option value="BH">Bahrain</option>
			<option value="BB">Barbados</option>
			<option value="BE">Belgium</option>

			<option value="BZ">Belize</option>
			<option value="BJ">Benin</option>
			<option value="BM">Bermuda</option>
			<option value="BT">Bhutan</option>
			<option value="BO">Bolivia</option>
			<option value="BA">Bosnia and Herzegovina</option>
			<option value="BW">Botswana</option>
			<option value="BR">Brazil</option>
			<option value="VG">British Virgin Islands</option>

			<option value="BN">Brunei</option>
			<option value="BG">Bulgaria</option>
			<option value="BF">Burkina Faso</option>
			<option value="BI">Burundi</option>
			<option value="KH">Cambodia</option>
			<option value="CA">Canada</option>
			<option value="CV">Cape Verde</option>
			<option value="KY">Cayman Islands</option>
			<option value="TD">Chad</option>

			<option value="CL">Chile</option>
			<option value="C2">China</option>
			<option value="CO">Colombia</option>
			<option value="KM">Comoros</option>
			<option value="CK">Cook Islands</option>
			<option value="CR">Costa Rica</option>
			<option value="HR">Croatia</option>
			<option value="CY">Cyprus</option>
			<option value="CZ">Czech Republic</option>

			<option value="CD">Democratic Republic of the Congo</option>
			<option value="DK">Denmark</option>
			<option value="DJ">Djibouti</option>
			<option value="DM">Dominica</option>
			<option value="DO">Dominican Republic</option>
			<option value="EC">Ecuador</option>
			<option value="SV">El Salvador</option>
			<option value="ER">Eritrea</option>
			<option value="EE">Estonia</option>

			<option value="ET">Ethiopia</option>
			<option value="FK">Falkland Islands</option>
			<option value="FO">Faroe Islands</option>
			<option value="FM">Federated States of Micronesia</option>
			<option value="FJ">Fiji</option>
			<option value="FI">Finland</option>
			<option value="FR">France</option>
			<option value="GF">French Guiana</option>
			<option value="PF">French Polynesia</option>

			<option value="GA">Gabon Republic</option>
			<option value="GM">Gambia</option>
			<option value="DE">Germany</option>
			<option value="GI">Gibraltar</option>
			<option value="GR">Greece</option>
			<option value="GL">Greenland</option>
			<option value="GD">Grenada</option>
			<option value="GP">Guadeloupe</option>
			<option value="GT">Guatemala</option>

			<option value="GN">Guinea</option>
			<option value="GW">Guinea Bissau</option>
			<option value="GY">Guyana</option>
			<option value="HN">Honduras</option>
			<option value="HK">Hong Kong</option>
			<option value="HU">Hungary</option>
			<option value="IS">Iceland</option>
			<option value="IN">India</option>
			<option value="ID">Indonesia</option>

			<option value="IE">Ireland</option>
			<option value="IL">Israel</option>
			<option value="IT">Italy</option>
			<option value="JM">Jamaica</option>
			<option value="JP">Japan</option>
			<option value="JO">Jordan</option>
			<option value="KZ">Kazakhstan</option>
			<option value="KE">Kenya</option>
			<option value="KI">Kiribati</option>

			<option value="KW">Kuwait</option>
			<option value="KG">Kyrgyzstan</option>
			<option value="LA">Laos</option>
			<option value="LV">Latvia</option>
			<option value="LS">Lesotho</option>
			<option value="LI">Liechtenstein</option>
			<option value="LT">Lithuania</option>
			<option value="LU">Luxembourg</option>
			<option value="MG">Madagascar</option>

			<option value="MW">Malawi</option>
			<option value="MY">Malaysia</option>
			<option value="MV">Maldives</option>
			<option value="ML">Mali</option>
			<option value="MT">Malta</option>
			<option value="MH">Marshall Islands</option>
			<option value="MQ">Martinique</option>
			<option value="MR">Mauritania</option>
			<option value="MU">Mauritius</option>

			<option value="YT">Mayotte</option>
			<option value="MX">Mexico</option>
			<option value="MN">Mongolia</option>
			<option value="MS">Montserrat</option>
			<option value="MA">Morocco</option>
			<option value="MZ">Mozambique</option>
			<option value="NA">Namibia</option>
			<option value="NR">Nauru</option>
			<option value="NP">Nepal</option>

			<option value="NL">Netherlands</option>
			<option value="AN">Netherlands Antilles</option>
			<option value="NC">New Caledonia</option>
			<option value="NZ">New Zealand</option>
			<option value="NI">Nicaragua</option>
			<option value="NE">Niger</option>
			<option value="NU">Niue</option>
			<option value="NF">Norfolk Island</option>
			<option value="NO">Norway</option>

			<option value="OM">Oman</option>
			<option value="PW">Palau</option>
			<option value="PA">Panama</option>
			<option value="PG">Papua New Guinea</option>
			<option value="PE">Peru</option>
			<option value="PH">Philippines</option>
			<option value="PN">Pitcairn Islands</option>
			<option value="PL">Poland</option>
			<option value="PT">Portugal</option>

			<option value="QA">Qatar</option>
			<option value="CG">Republic of the Congo</option>
			<option value="RE">Reunion</option>
			<option value="RO">Romania</option>
			<option value="RU">Russia</option>
			<option value="RW">Rwanda</option>
			<option value="VC">Saint Vincent and the Grenadines</option>
			<option value="WS">Samoa</option>
			<option value="SM">San Marino</option>

			<option value="ST">São Tomé and Príncipe</option>
			<option value="SA">Saudi Arabia</option>
			<option value="SN">Senegal</option>
			<option value="SC">Seychelles</option>
			<option value="SL">Sierra Leone</option>
			<option value="SG">Singapore</option>
			<option value="SK">Slovakia</option>
			<option value="SI">Slovenia</option>
			<option value="SB">Solomon Islands</option>

			<option value="SO">Somalia</option>
			<option value="ZA">South Africa</option>
			<option value="KR">South Korea</option>
			<option value="ES">Spain</option>
			<option value="LK">Sri Lanka</option>
			<option value="SH">St. Helena</option>
			<option value="KN">St. Kitts and Nevis</option>
			<option value="LC">St. Lucia</option>
			<option value="PM">St. Pierre and Miquelon</option>

			<option value="SR">Suriname</option>
			<option value="SJ">Svalbard and Jan Mayen Islands</option>
			<option value="SZ">Swaziland</option>
			<option value="SE">Sweden</option>
			<option value="CH">Switzerland</option>
			<option value="TW">Taiwan</option>
			<option value="TJ">Tajikistan</option>
			<option value="TZ">Tanzania</option>
			<option value="TH">Thailand</option>

			<option value="TG">Togo</option>
			<option value="TO">Tonga</option>
			<option value="TT">Trinidad and Tobago</option>
			<option value="TN">Tunisia</option>
			<option value="TR">Turkey</option>
			<option value="TM">Turkmenistan</option>
			<option value="TC">Turks and Caicos Islands</option>
			<option value="TV">Tuvalu</option>
			<option value="UG">Uganda</option>

			<option value="UA">Ukraine</option>
			<option value="AE">United Arab Emirates</option>
			<option value="GB">United Kingdom</option>
			<option value="UY">Uruguay</option>
			<option value="VU">Vanuatu</option>
			<option value="VA">Vatican City State</option>
			<option value="VE">Venezuela</option>
			<option value="VN">Vietnam</option>
			<option value="WF">Wallis and Futuna Islands</option>

			<option value="YE">Yemen</option>
			<option value="ZM">Zambia</option>
		</select></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="zip">Post Code</label></td>
		<td></td>
		<td><input id="zip" name="zip" style="width: 41px" /></td>
	</tr>
	<tr>
		<td width="30%" align="right">Company</td>
		<td></td>
		<td><input id="company" name="company" /></td>
	</tr>
	<tr>
		<td width="30%" align="right">Phone</td>
		<td></td>
		<td><input id="phone" name="phone" /></td>
	</tr>
	<tr>
		<td width="30%" align="right">Fax</td>
		<td></td>
		<td><input id="fax" name="fax" /></td>
	</tr>
	<tr>
		<td width="30%" align="right">Mobile</td>
		<td></td>
		<td><input id="mobile" name="mobile" /></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="email">Email </label></td>
		<td></td>
		<td><input id="email" name="email" style="width: 218px" /></td>
	</tr>
	<tr>
		<td width="30%" align="right">Job Description</td>
		<td></td>
		<td><textarea id="job_desc" name="job_desc" rows="10" cols="25"></textarea></td>
	</tr>
	<tr>
		<td width="30%" align="right">Comments</td>
		<td></td>
		<td><textarea id="comments" name="comments" rows="10" cols="25"></textarea></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="email">URL </label></td>
		<td></td>
		<td><input id="url" name="url" style="width: 281px"/></td>
	</tr>
	<tr>
		<td width="30%" align="right">Customer Reference</td>
		<td></td>
		<td><input id="customer_ref" name="customer_ref"
			style="width: 80px"></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="ccnumber">Card
		Number</label></td>
		<td></td>
		<td><input id="ccnumber" name="ccnumber" /></td>
	</tr>
	<tr>
		<td width="30%" align="right"><label for="ccnameoncard">Name
		on Card</label></td>
		<td></td>
		<td><input id="ccnameoncard" name="ccnameoncard"
			style="width: 276px"></td>
	</tr>
	<tr>
		<td width="30%" align="right">Expiry</td>
		<td></td>
		<td><span class="month_label">MM</span> <span class="month_input"><input
			id="ccexpirymonth" name="ccexpirymonth" style="width: 20px" /></span> <span
			class="year_label">YY</span> <span class="year_input"><input
			id="ccexpiryyear" name="ccexpiryyear" style="width: 20px" /></span></td>
	</tr>
	<tr>
		<td colspan="3" align="center"><input type="submit" value="ADD" /></td>
	</tr>
</table>
</form>
</body>
</html>
